import Jama.Matrix;
import core.Phone;
import core.Speaker;
import org.apache.commons.lang3.ArrayUtils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: lahiru
 * Date: 3/26/14
 * Time: 3:05 PM
 * To change this template use File | Settings | File Templates.
 */
public class Test {
    public static void main(String[] args) {

        double p = 9.643200860851325E-4;
        System.out.println(p);
        NumberFormat formatter = new DecimalFormat("###.###############");
        String f = formatter.format(p);
        System.out.println(f);
//        System.out.println();

                System.exit(0);

        double[][] temp = new double[1][2];
        temp[0][0] = 4.5;
        temp[0][1] = 6.5;
        Matrix m = new Matrix(temp);
        Matrix x = m.times(0.2);

        System.out.println(m.getRowDimension());
        System.out.println(m.getColumnDimension());

        System.out.println(x.get(0,0));
        System.out.println(x.get(0,1));

        System.exit(0);

        String location = "/media/Data/speaker-effects/objects/h1_011.ser";

        try {
            FileInputStream fileIn = new FileInputStream(location);
            ObjectInputStream in = new ObjectInputStream(fileIn);
            Speaker speaker = (Speaker) in.readObject();

            int totalPhoneCount = 0;
            Map<Integer, Phone> phones = speaker.getPhones();
            for (int pid : phones.keySet()) {
                Phone phone = phones.get(pid);
                //phone.averageVector(); //TODO should only do once when finished
                int count = phone.getCount();
                totalPhoneCount = totalPhoneCount + count;
                System.out.println("phone id " + pid + " count " + count);

//                phone.averageVector();

//                if (pid == 41){
//                    for (Double d: phone.getVector()){
//                        System.out.println(d);
//                    }
//                }

            }
            System.out.println("Total count " + totalPhoneCount);


            in.close();
            fileIn.close();
        } catch (IOException i) {
            i.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }





        /*    TODO code for serializing speaker object
        //save the speaker data
                String location = null;
                try {
                    location = saveObjects +"h"+i+"_"+speaker.getId()+".ser";
                    FileOutputStream fileOut =
                            new FileOutputStream(location);
                    ObjectOutputStream out = new ObjectOutputStream(fileOut);
                    out.writeObject(speaker);
                    out.close();
                    fileOut.close();
                } catch (IOException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
                System.out.printf("Serialized data is saved in " + location);
         */


//        String first = "0.01408638 0.01424262 0.01407021 0.01409048 0.01407428 ";
//        String second = "0.01408638 0.01424262 0.01407021 0.01409048 0.01416876 ";
//
//        for (String str : first.trim().split(" ")){
//            System.out.println(" the string is " + str);
//        }
//
//        core.Phone phone = new core.Phone((first.trim()).split(" "), 1 , 5);
//        phone.addActivations((second.trim()).split(" "));
//
//        System.out.println(phone.getCount());
//        System.out.println(phone.getId());
//
//        for (Double d : phone.getVector()){
//            System.out.println(" the double value is " + d);
//        }
//
//        phone.averageVector();
//
//        for (Double d : phone.getVector()){
//            System.out.println(" the double value is " + d);
//        }


    }
}
